/**
  ******************************************************************************
  * @file    main.c
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
#include "system.h"

#include "FreeRTOS.h"
#include "task.h"


static void task1(void *args __attribute((unused)))
{
    for (;;) {
        vTaskDelay(pdMS_TO_TICKS(250));
        my_printf("Task1 running\r\n");
    }
}

static void task2(void *args __attribute((unused)))
{

    for (;;) {
        vTaskDelay(pdMS_TO_TICKS(100));
        my_printf("Task2 running\r\n");
    }
}

/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /*
     * 被注释原因，这个地方会开启sysTick中断，进入到FreeRTOS的xPortSysTickHandler.这里会触发异常
     * FreeRTOS还没有初始化完成
    */
    //HAL_Init();

    /* Configure the system clock to 64 MHz */
    SystemClock_Config();

    Usart_Config(115200);

    xTaskCreate(task1, "task1", 100, NULL, configMAX_PRIORITIES-1, NULL);
    xTaskCreate(task2, "task2", 100, NULL, configMAX_PRIORITIES-2, NULL);
    vTaskStartScheduler();
    /* Infinite loop */
    while (1)
    {
    }
}
